import java.util.*;

public class SetDemo {
    protected static void setLoop() {
        // 生成100个0到100的随机数，添加到 集合 中
        HashSet<Integer> randSet = new HashSet<Integer>();
        Random intRand = new Random();
        for (int i=0;i<100;++i) {
            randSet.add(intRand.nextInt(101));
        }
        // 集合遍历
        int loop=0;
        for (Integer val : randSet) {
            System.out.println("setLoop, " + loop + ",\t vaule:" + val);
            ++loop;
        }
    }

    protected static void setSort(){
        // 生成100个0到100的随机数，添加到 集合 中
        HashSet<Integer> randSet = new HashSet<Integer>();
        Random intRand = new Random();
        for (int i=0;i<100;++i) {
            randSet.add(intRand.nextInt(101));
        }

        // 按默认排序后遍历
        ArrayList<Integer> valList = new ArrayList<Integer>(randSet);
        Collections.sort(valList);
        int loop=0;
        for (Integer val : valList) {
            System.out.println("setSort, " + loop + ",\t vaule:" + val);
            ++loop;
        }
    }
    protected static void demoLogic() {
        DateTimeDemo.logTs("setLoop");
        setLoop();

        DateTimeDemo.logTs("setSort");
        setSort();
    }

}
